package util;

import java.util.Map;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class SessaoFactory {
	
	private static HttpSession session;

	public SessaoFactory(){
		
	}
	
	public HttpSession getSession() {
		return session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
	}
	
	public Map<String, Object> getRequestMap(){
		return FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
	}
	
	public void setSession(String argumento, Object object) {
		session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
		session.setAttribute(argumento, object);
	}
	
	public void destruir(){
		session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		session.invalidate();
	}
	
	public boolean sessaoExiste(String argumento){
		boolean result = (getSession().getAttribute(argumento) != null);
		return result;
	}
	
}
